package com.csp.main.utils;

import java.security.SecureRandom;
import java.util.Date;
import java.util.Random;

/**
 * @Classname GetVerCode
 * @Description done
 * @Date 2022/6/5 9:17
 * @Created by csp
 */
public class GetVerCode {
    private static final String SYMBOLS = "0123456789";

    private static final Random RANDOM = new SecureRandom();

    public static String generateVerCode() {
        char[] nonceChars = new char[6];
        for (int i = 0; i < nonceChars.length; i++) {
            nonceChars[i] = SYMBOLS.charAt(RANDOM.nextInt(nonceChars.length));
        }
        return new String(nonceChars);
    }

    public static int getMinute(Date fromDate, Date toDate) {
        return (int) (toDate.getTime() - fromDate.getTime()) / (60 * 1000);
    }
}
